Open
Conversation
* Add a new response structure: a separate `comparison_results` field, used only when comparing in a time-dimensional query. * Add `meta.time_label_result_indices` to response (exclusive to internal API). Makes it easier for FE to find buckets for time labels.
This is currently only used by the main graph, which is going to move to a new endpoint in this PR. * The CSV export is currently ignoring comparisons * the `&compare=previous_period` option in Stats API v1 is ignored by the timeseries endpoint
13 tasks
ukutaht
approved these changes
Apr 14, 2026
| end | ||
|
|
||
| def present_index(time_labels, query) do | ||
| now = DateTime.now!(query.timezone) |
Contributor
There was a problem hiding this comment.
Feels like this should be using query.now as well (?)
Contributor
Author
There was a problem hiding this comment.
Would make sense, yes. I'll keep that in mind in case we end up actually using present_index on the FE. Otherwise, we'll remove the field.
* Add generic graph component and use it for main graph * Remove superfluous mobile related code * Add isTouchDevice state and touch-device specific zoom instructions * Move useMainGraphWidth * Center tooltip * Adjust tooltip position * Clarify pointerup * Extract fetching main graph and remapping main graph data * Unify BE and FE change calculations * Stop wrapping change arrow, unify with ComparisonTooltipContent * Exports * Attempt partial logic * Draw dashed partial periods at the start and end of main series * Simplify * Clarify series * Better types * Make remapAndFillData take accessors * Get metric label using utility * Refactor value and comparisonValue to numericValue and comparisonNumericValue * Refactor outerValue and comparisoOuterValue to value and comparisonValue * Fix format * Fix type error in test * No need to assert isPartial * Fix issue with full crash when switching between periods while tooltip * Add necessary types * Handle comparison_partial_time_labels * Handle [null] style result items * Hint expected tick count to y axis nicing * Remove old line graph * Clarify graph inputs * Add MetricValue type * Extract logic to read first and last time labels * Clarify remapAndFillData * Stop requesting for present_index as it is unused * Clarify getLineSegments comment and refactor getNumericValue arg * Remove unnecessary guard and unnecessary return value * Refactor x tick values function and the way it is passed around * Add getXDomain function * Add tests for some graph.ts utils * Add constants to top of graph.tsx, move utiltiy types to bottom
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This PR gets rid of the /main-graph endpoint in favor of the new API v2 based /query endpoint, and builds a whole new hand-rolled graph with D3.
Backend: This PR -- see description below
Frontend: #6159 (which has now been merged into this one)
1. Change the result format of comparison results (when time dimension breakdown)
With this PR, the query API starts returning
comparison_resultsas a separate response field ifdimensions == [time:*], while breakdown and aggregate responses keepcomparisonsnested for each row in the originalresultslist.In hindsight, the new comparison results format could have been avoided by filling in all the missing buckets instead. This would have let us avoid returning a bunch of meta fields (
time_labels,comparison_time_labels,time_label_indices,comparison_time_label_indices, andempty_metrics).The main reason I went with this approach was to prepare comparisons for a public API release (playing well with time_labels), but since it’s still far from perfect (a noisy query.include + meta; difficult for the client to read the data), we’ll still need to re-evaluate this. We should also carefully consider what to do with
include.total_rowsand multi-dimensional (time + non-time) breakdowns, where zipping comparison <> main results gets tricky.2. Add new
response.metaandquery.includefieldsNote: all these flags are internal-use only. Nothing gets released into the public API
meta.comparison_time_labelsmeta.time_labelsbut for generating the comparison plotinclude.time_labels && include.comparemeta.present_indexinclude.present_indexmeta.time_label_result_indicesmeta.time_labels) of indices where each item corresponds to an index in theresultslist ornullwhen there is no result for that bucket. Makes it much easier for the frontend to understand the data.include.time_label_result_indicesmeta.comparison_time_label_result_indicesmeta.time_label_result_indicesbut for comparison resultsinclude.time_label_result_indices && include.comparemeta.partial_time_labelsinclude.partial_time_labelsmeta.comparison_partial_time_labelsmeta.partial_time_labelsbut for comparison resultsinclude.partial_time_labels && include.comparemeta.empty_metricsquery.metrics = ['visitors', 'time_on_page'], thenmeta.empty_metrics = [0, null]. Makes it possible for the frontend to fill in missing buckets without re-defining empty metrics.include.empty_metrics && "event:goal" not in query.dimensions- there shouldn't be any need to ask for empty metrics in the goal breakdown, but this makes it clear that there's a conflict (possibly multiple revenue currencies).3. Remove old code
4. Transform main_graph_test.exs
A major rewrite of main_graph_test.exs - populate_stats and other tests setup remained the same, but the request is now made against the new endpoint and the assertions on the returned data structures have changed significantly.
Tests
Changelog
Documentation
Dark mode